{include file="public/head"}
{include file="public/left"}
<!-- content -->
<div class="main_02_r">

    <!--内容区域-->
    <div class="site_01">
        <span>当前位置：</span><a href="#"> 城事社</a><i>></i><a href="#">平台公告</a>
    </div>

    <div class="nrq_01">
        <div class="gg_01">
            <span class="on">平台公告</span>
        </div>
        <div class="gg_02">
            <div class="gg_03">
                <div class="gg_03_t">
                    <a href="javascript:void(0);" class="a1 fbgg_click">发布公告</a>
                    <em class="fr">
                        <form method="get">
                            <input type="text" name="search" value="{$search}" placeholder="请输入平台公告标题关键词" class="gg_03_txt" />
                            <input type="submit" value="" class="gg_03_btn" />
                        </form>
                    </em>
                </div>
                <div class="gg_03_c">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <th>时间</th>
                            <th>标题</th>
                            <th>操作</th>
                        </tr>
                        {volist name="arr" id="vo"}
                        <tr>
                            <td>{$vo.create_time|substr=0,-3}</td>
                            <td>{$vo.title}</td>
                            <td><a href="javascript:lookContent('{$vo.id}');" class="tcxq_click">查看</a></td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="gg_03_b">
                    <div class="fl">
                        <span>共 <i>{$arr->total()}</i> 条</span><span>每页 <i>{$arr->listRows()}</i> 条</span>
                    </div>
                    <div class="fr">
                        {$arr->render()}
                    </div>
                </div>
            </div>
        </div>

    </div>

</div>
</div>

<!--公告详情弹窗-->
<div class="ggtcxq_01">
    <div class="ggtcxq_bg"></div>
    <div class="ggtcxq_c">
        <div class="ggtcxq_cfr">
            <div class="ggtcxqc_t">
                <span>公告详情</span><a href="javascript:void(0);" class="close"></a>
            </div>
            <div class="ggtcxqc_c">
                <div class="ggtcxqc_c_t">
                    <h1 class="title_ajax">     </h1>
                    <p class="create_time_ajax">     </p>
                </div>
                <div class="ggtcxqc_c_c">
                    <p class="centext_ajax">     </p>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(".tcxq_click").each(function () {
        $(this).click(function () {
            $(".ggtcxq_01").show();
            $(".ggtcxq_01 .ggtcxq_c").css({ "margin-top": "-" + $(".ggtcxq_01 .ggtcxq_c").height() / 2 + "px" });
        });
    });
    $(".ggtcxq_01 .close").click(function () {
        $(".ggtcxq_01").hide();
    });
    $(".ggtcxq_01 .ggtcxq_bg").click(function () {
        $(".ggtcxq_01").hide();
    });
</script>

<!--发布公告弹窗-->
<div class="ggtcxq_02">
    <div class="ggtcxq_bg"></div>
    <div class="ggtcxq_c">
        <div class="ggtcxq_cfr">
            <div class="ggtcxqc_t">
                <span>发布公告</span><a href="javascript:void(0);" class="close"></a>
            </div>
            <div class="fbgg_01">
                <form class="ajax_form_add" action="{:url('notice/ajax_add')}">
                <p><span>标题</span><input type="text" name="title" class="fbgg_01_txt" /></p>
                <p><span>内容</span><textarea rows="1" name="context" cols="1"></textarea></p>
                <p><span>&nbsp;</span><input type="button" value="确定" class="fbgg_01_btn ajax_submit_add"/></p>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(".fbgg_click").click(function () {
        $(".ggtcxq_02").show();
        $(".ggtcxq_02 .ggtcxq_c").css({ "margin-top": "-" + $(".ggtcxq_02 .ggtcxq_c").height()/2 +"px"});
    });
    $(".ggtcxq_02 .close").click(function () {
        $(".ggtcxq_02").hide();
    });
    $(".ggtcxq_02 .ggtcxq_bg").click(function () {
        $(".ggtcxq_02").hide();
    });
</script>
<script type="text/javascript">
    $(function(){
        var layer = layui.layer,form = layui.form;
        //发布公告
        $(".ajax_submit_add").click(function(){
            var url = $('.ajax_form_add').attr("action")?$('.ajax_form_add').attr("action"):"{:url()}";
            var data = $('.ajax_form_add').serialize();
            ajax_psot(url,data);
        });

        function ajax_psot(url,data){
            $.ajax({
                url:url,
                type: "POST",//方法类型
                // dataType: "json",//预期服务器返回的数据类型
                data: data,
                success: function (data) {
                    if (data.code === 1) {
                        layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 1,time:1000},function(){
                            window.location.href=data.url;
                        });
                    }else{
                        layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                            /*if(data.url){
                                window.location.href=data.url;
                            }else{
                                location.reload();
                            }*/
                        });
                    }
                },
                error : function() {
                    layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                        //location.reload();
                    });
                }
            });
        }

    })

    function lookContent(id){
        $.ajax({
            url:"{:url('notice/lookContent')}",
            type: "POST",//方法类型
            // dataType: "json",//预期服务器返回的数据类型
            data: {"id":id},
            success: function (data) {
                if (data.code === 1) {
                    $(".centext_ajax").html(data.data.context);
                    $(".title_ajax").html(data.data.title);
                    $(".create_time_ajax").html(data.data.create_time.substring(0,-3));
                }else{
                    layer.msg("<span style='margin-left: 18px;'>"+data.msg+"</span>",{icon: 2,time:1000},function(){
                        $(".ggtcxq_01").hide();
                    });
                }
            },
            error : function() {
                layer.msg("<span style='margin-left: 18px;'>请求错误,请联系管理员</span>",{icon: 0,time:1000},function(){
                    //location.reload();
                });
            }
        });
    }
</script>

<!-- content -->
{include file="public/foot"}